<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>コントロールパネル</title>
    <link href="./assets/styles/default.css" rel="stylesheet" />
	<script src="./assets/scripts/libs/jquery-1.7.1.min.js" type="text/javascript"></script>
	<script src="./assets/scripts/import.js" type="text/javascript"></script>
	<script src="./assets/scripts/plugins/zip2address.js" type="text/javascript"></script>
</head>
<body>
{{$zhead}}
<div id="container">
	{{$zmenu}}
    <article>
    	<h2><span>&nbsp;</span>会員管理<p><a href="javascript:;">Open Plugins</a></p></h2>
        <nav>
        	<ul>
				<li class="active"><a href="{{'Home/user/index'|U}}"><span>会員検索</span></a></li>
				<li><a href="{{'Home/user/insert'|U}}"><span>会員登録</span></a></li>
			</ul>
        </nav>
		<section id="content">
			<h3>会員更新</h3>
			<ul class="btns b20" style="position:relative;top:10px;">
			 <li class="btn left c"><a href="{{'Home/user/refer'|U}}?id={{$forms.id}}" >情報参照</a></li>
				<li class="btn center c"><a href="{{'Home/user/update'|U}}?id={{$forms.id}}" class="active">情報更新</a></li>
				<li class="btn center c"><a href="{{'Home/delivery/refer'|U}}?id={{$forms.id}}">配送先情報</a></li>
				<li class="btn center c"><a href="{{'Home/OrderManage/userGoods'|U}}?id={{$forms.id}}">注文情報</a></li>
			<li class="btn center c"><a href="{{'Home/email/emailRecord'|U}}?id={{$forms.id}}">メール履歴</a></li>
			</ul>
			
				{{if $show_massg}}
			
			<p class="message">会員情報を更新します。</p>
			<form name="fm" action="{{'Home/user/update'|U}}?id={{$forms.id}}" method="post" enctype="multipart/form-data">
				<h4><span>&nbsp;</span>基本情報</h4>
				<table class="formTable">
					<tbody>
					
					
						<tr>
							<th>登録日時</th>
							<td> {{$forms.c_time}}
								<input type="hidden" name="c_time" value="{{$forms.u_time}}" /></td>
						</tr>
						<tr>
							<th>更新日時</th>
							<td> {{$forms.u_time}}
								<input type="hidden" name="u_time" value="{{$forms.u_time}}" /></td>
						</tr>
						<tr>
							<th>システムID</th>
							<td>{{$forms.id}}<input type="hidden" name="id" value="{{$forms.id}}" /></td></td>
						</tr>
						
						
						
						<tr>
							<th class="must">状態</th>
							<td>
							<label><input type="radio" name="state" {{if $forms.state==1}}checked=true{{/if}} value="1" />通常</label>
								<label><input type="radio" name="state" {{if $forms.state==2}}checked=true{{/if}} value="2" />仮登録</label>
								<label><input type="radio" name="state" {{if $forms.state==3}}checked=true{{/if}} value="3" />退会</label>
							{{ $err_mes.state }}
							</td>
						</tr>
						<tr>
							<th class="must">ID</th>
							<td><input type="text" name="login_id" value="{{ $forms.login_id}}" /></td>
							{{$err_mes.login_id}}
						</tr>
						<tr>
							<th class="must">パスワード</th>
							<td>
								<input type="text" name="login_pwd" id="text_auth_pwd"  value="{{$forms.login_pwd}}" />
								{{$err_mes.login_pwd}}
							</td>
						</tr>
						<tr>
							<th class="must">会員氏名</th>
							<td>
								<input type="text" class="short" name="user_name1" value="{{$forms.user_name1}}" id="url" />
								<input type="text" class="short" name="user_name2" value="{{$forms.user_name2}}" />
								{{$err_mes.user_name1}}{{$err_mes.user_name2}}{{$err_mes.user_name}}
							</td>
						</tr>
						<tr>
							<th class="must">フリガナ</th>
							<td>
								<input type="text" class="short" name="user_name_furikana1" value="{{$forms.user_name_furikana1}}" />
								<input type="text" class="short" name="user_name_furikana2" value="{{$forms.user_name_furikana2}}" />
								{{$err_mes.user_name_furikana1}}{{$err_mes.user_name_furikana2}}
							</td>
						</tr>
						<tr>
							<th>貴医院名・貴技工所名</th>
							<td>
								<input type="text" class="text" name="workshop_name" value="{{$forms.workshop_name}}" />
								{{$err_mes.workshop_name}}
							</td>
						</tr>
						<tr>
							<th>フリガナ</th>
							<td>
								<input type="text" class="text" name="workshop_name_furikana" value="{{$forms.workshop_name_furikana}}" />
								{{$err_mes.workshop_name_furikana}}
							</td>
						</tr>
						<tr>
							<th class="must">郵便番号</th>
							<td class="floats">
								<input type="text" name="zipcode1" class="short" value="{{$forms.zipcode1}}" />
								<span> - </span>
								<input type="text" name="zipcode2" class="short" value="{{$forms.zipcode2}}" />
								<span class="btn_blank">
									<a href="javascript:;" style="position:relative;top:-2px;" class="searchAddress">住所検索</a>
								</span>
								{{$err_mes.zipcode}}{{$err_mes.zipcode1}}{{$err_mes.zipcode2}}
							</td>
						</tr>
						<tr>
							<th class="must">都道府県</th>
							<td>
								<select name="local_cd" id='select_id'>
									  {{html_options options=$dao_local selected=$forms.local_cd}}
								</select>
								{{$err_mes.local_cd}}
							</td>
						</tr>
						<tr>
							<th class="must">市区町村</th>
							<td><input type="text" name="treet_name" id="treet_name" class="text" value="{{$forms.treet_name}}" />
							{{$err_mes.treet_name}}</td>
							
						</tr>
						<tr>
							<th class="must">以降の住所</th>
							<td><input type="text" name="address" class="text" value="{{$forms.address}}" /> {{$err_mes.address}}</td>
						</tr>
						<tr>
							<th class="must">電話番号</th>
							<td>
								<input type="text" class="short" name="tel_number1" value="{{$forms.tel_number1}}" /> -
								<input type="text" class="short" name="tel_number2" value="{{$forms.tel_number2}}" /> -
								<input type="text" class="short" name="tel_number3" value="{{$forms.tel_number3}}" />
								{{$err_mes.tel_number}}{{$err_mes.tel_number1}}{{$err_mes.tel_number2}}{{$err_mes.tel_number3}}
							</td>
						</tr>
						<tr>
							<th>FAX番号</th>
							<td>
								<input type="text" class="short" name="mobile_number1" value="{{$forms.mobile_number1}}" /> -
								<input type="text" class="short" name="mobile_number2" value="{{$forms.mobile_number2}}" /> -
								<input type="text" class="short" name="mobile_number3" value="{{$forms.mobile_number3}}" />
								{{$err_mes.mobile_number}}{{$err_mes.mobile_number1}}{{$err_mes.mobile_number2}}{{$err_mes.mobile_number3}}
							</td>
						</tr>
						<tr>
							<th class="must">E-Mail</th>
							<td><input type="text" name="email" class="text" value="{{$forms.email}}" />
							{{$err_mes.email}}</td>
						</tr>
						<tr>
							<th>メルマガ購読（PC）</th>
							<td><label><input type="checkbox" name="send"  {{if $forms.send=='1'}} checked="true"{{/if}} value="1" />購読する</label></td>
						</tr>
						<tr>
							<th>退会理由</th>
							<td>
								退会日時：{{$forms.r_time}}<br />
								
								<textarea name="retreat">{{$forms.retreat}}</textarea>
								{{$err_mes.retreat}}
							</td>
						</tr>
			      <tr>
							<th>生年月</th>
							<td class="floats">
						{{ html_options id='year4' name='year4' options=$year4 selected=$forms.birthday_year}}
						{{ html_options id='moon4' name='moon4' options=$moon4 selected=$forms.birthday_m}}
						{{$err_mes.birthday}}		
							</td>
							
						</tr>
						<tr>
							<th>性別</th>
							<td>
								<label><input type="radio" name="sex" {{if $forms.sex==1}}checked=true{{/if}} value="1" />女性</label>
								<label><input type="radio" name="sex" {{if $forms.sex==2}}checked=true{{/if}} value="2" />男性</label>
								<label><input type="radio" name="sex" {{if $forms.sex==3}}checked=true{{/if}} value="3" />指定なし</label>
							
							</td>
						</tr>
					</tbody>
				</table>

				<p class="button">
					<button type="button" id="btn_update" class="submit"><span>更新</span></button>
				</p>
			</form>
		
		{{else}}
			<p class="message">{{$message}}</p>
			
			
			<ul class="result_btn clear" style="margin-top:20px;">
                <li><a href="{{'Home/User/index'|U}}">一覧に戻る</a></li>
                <li><a href="{{'Home/User/insert'|U}}">続けて新規登録する</a></li>
            {{if isset($forms.id)}}
                <li><a href="{{'Home/User/update'|U}}?id={{$forms.id}}">登録した内容を更新する</a></li>
            {{/if}}
        	</ul>
			
		{{/if}}
		
		</section>
	</article>
</div>
<script type="text/javascript">
		$(function(){
	//search address
		$('.searchAddress').live('click',function(){
			var p = $(this).closest("td");
			var table = $(this).closest("table");
			var post1 = $('input[name=zipcode1]').val();
			var post2 = $('input[name=zipcode2]').val();
			if(post1 == "" || post2 == ""){return;}
			var post = post1 +""+ post2;
			zip2address(post, function(address) {
			if (address) {
				$("#treet_name").val(address.city);
				$("#uniform-select_id>span").text(address.pref);
				//$("#select_id").val(address.index)
				$("#select_id").children().attr("selected",false);
				$("#select_id").find("option[value='"+(address.index+1)+"']").attr("selected",true);
		
			
			}
			else {
				alert("見つかりませんでした。。\n入力した郵便番号に誤りがないか、お確かめ下さい。");
			}
		});
			
		});
		});
</script>
{{$zfooter}}
</body>
</html>